//
//  UIView+Extension.h
//  TableDemo
//
//  Created by jutuo on 2020/3/28.
//  Copyright © 2020 jutuo. All rights reserved.
//


#import <UIKit/UIKit.h>
#import "CAShapeLayer+Extension.h"
NS_ASSUME_NONNULL_BEGIN

@interface UIView (Extension)
@property (nonatomic, assign) CGFloat x;
@property (nonatomic, assign) CGFloat y;
@property (nonatomic, assign) CGFloat width;
@property (nonatomic, assign) CGFloat height;
@property (nonatomic, assign) CGFloat centerX;
@property (nonatomic, assign) CGFloat centerY;
@property (nonatomic, assign) CGSize size;
@property (nonatomic, assign) CGPoint origin;
@property (nonatomic, assign) CGFloat top;
@property (nonatomic, assign) CGFloat left;
@property (nonatomic, assign) CGFloat bottom;
@property (nonatomic, assign) CGFloat right;
@property (readonly) CGPoint bottomLeft;
@property (readonly) CGPoint bottomRight;
@property (readonly) CGPoint topRight;

- (void)removeAllSubviews;
- (void)removeViewWithTag:(NSInteger)tag;
- (void)removeViewWithTags:(NSArray *)tagArray;
- (void)removeViewWithTagLessThan:(NSInteger)tag;
- (void)removeViewWithTagGreaterThan:(NSInteger)tag;
- (UIViewController *)controller;



/**
 *  添加阴影
 */
/**
 *  添加圆角和边的宽度
 */
- (void)cornerRadius:(CGFloat)cornerRadius masksToBounds:(BOOL)masksToBounds;

/**
 *  添加边的宽度
 */
- (void)borderColor:(UIColor *)borderColor borderWidth:(CGFloat)borderWidth;

- (void)shadowRadius:(CGFloat)shadowRadius shadowOffset:(CGSize)shadowOffset;
- (void)shadowRadius:(CGFloat)shadowRadius shadowOffset:(CGSize)shadowOffset shadowOpacity:(float)shadowOpacity shadowColor:(UIColor *)shadowColor;

/**
 * 添加圆角
 */
- (void)cornerRadius:(CGFloat)radius
borderWidth:(CGFloat)borderWidth
         borderColor:(UIColor *_Nullable)borderColor;

- (void)cornerRadius:(CGFloat)radius;
- (void)cornerRadius:(CGFloat)radius corners:(UIRectCorner)corners;

- (void)cornerRadius:(CGFloat)radius
    corners:(UIRectCorner)corners
borderWidth:(CGFloat)borderWidth
borderColor:(UIColor *_Nullable)borderColor
                    borderLineJoin:(CGLineJoin)borderLineJoin layerName:(NSString * _Nullable)name;

- (void)cornerRadiusWithtopLeft:(CGFloat)topLeftRadius bottomLeft:(CGFloat)bottomLeftRadius topRight:(CGFloat)topRightRadius bottomRight:(CGFloat)bottomRightRadius;

/**
 绘制虚线 -----
 * @paramer lineWidth: 线粗细
 * @paramer lineLength ： 线长
 * @paramer lineSpacing : 间隔
 * @paramer lineColor : 线的颜色
 */

- (void)drawDashLineWithlineWidth:(CGFloat)lineWidth lineLength:(CGFloat)lineLength lineSpacing:(CGFloat)lineSpacing lineColor:(UIColor *)lineColor;

/**
 绘制虚线框  ----
          |    |
           ----

 * @paramer lineWidth: 线粗细
 * @paramer lineLength ： 线长
 * @paramer lineSpacing : 间隔
 * @paramer lineColor : 线的颜色
 */
- (void)drawDashLineBoxWithlineWidth:(CGFloat)lineWidth lineLength:(CGFloat)lineLength lineSpacing:(CGFloat)lineSpacing lineColor:(UIColor *)lineColor;
@end


@interface UIView  (UIGestureRecognizer)
- (void)setGestureRecognizer:(UIGestureRecognizer *)gestureRecognizer;
- (void)addTapGesture:(void(^)(UITapGestureRecognizer *tap))handle;
- (void)addDoubleTapGesture:(void(^)(void))handle;
@end

@interface UIView (Reusable)
@property (nonatomic, strong) NSMutableDictionary *reuseableViewInfo;
@property (nonatomic, strong) NSString *reuseIdentifier;
//重用视图
- (UIView *)dequeueReusableViewWithIdentifier:(NSString *)identifier;
//添加到重用池并添加视图
- (void)addViewToReuseQueue:(UIView *)view;
//移除多余的视图并将UIViewReusableModel中的reuseIndex复位
- (void)removeRedundantViewFromReuseQueue;
@end

@interface UIViewReusableModel : NSObject
//存放重用的视图
@property (nonatomic, strong) NSMutableArray *reusableViews;
//当前重用位置
@property (nonatomic, assign) NSInteger reuseIndex;
@end
NS_ASSUME_NONNULL_END
